//
//  MyAdviceViewController.m
//  LastOne
//
//  Created by 小柠檬 on 15/11/10.
//  Copyright © 2015年 sc. All rights reserved.
//

#import "MyAdviceViewController.h"
#import <SKPSMTPMessage.h>
#import "FitHeader.h"
@interface MyAdviceViewController ()<SKPSMTPMessageDelegate>

@end

@implementation MyAdviceViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.title = @"意见反馈";
    self.view.backgroundColor = [UIColor whiteColor];
    
    SKPSMTPMessage *myMessage = [[SKPSMTPMessage alloc]init];
    myMessage.fromEmail = @"rwzrwz449@163.com";
    myMessage.toEmail = @"552789178@qq.com";
    myMessage.relayHost = @"smtp.163.com";
    
    myMessage.requiresAuth = YES;
    if (myMessage.requiresAuth) {
        myMessage.login = @"rwzrwz449@163.com";
        myMessage.pass = @"rwzrwz449@";
    }
    myMessage.wantsSecure = YES;
    myMessage.subject = @"asd";
    myMessage.delegate = self;
    
    
    UITextView *adviceTV = [[UITextView alloc]init];
    adviceTV.frame = CGRectMake(10 * FitWidth, 10 * FitHeight, 355 * FitWidth, 200 * FitHeight);
    adviceTV.text = [NSString stringWithFormat:@"%@", adviceTV.text];
    adviceTV.backgroundColor = [UIColor colorWithRed:0.83 green:0.94 blue:0.92 alpha:1];
    adviceTV.returnKeyType = UIReturnKeySend;
    [self.view addSubview:adviceTV];
    
    
    NSDictionary *dic = [NSDictionary dictionaryWithObjectsAndKeys:@"text/plain;charset = UTF-8", kSKPSMTPPartContentTransferEncodingKey, adviceTV.text, kSKPSMTPPartMessageKey,  @"8bit", kSKPSMTPPartContentTransferEncodingKey, nil];
    
    myMessage.parts = [NSArray arrayWithObjects:dic, nil];
    
    [myMessage send];
    
    
}

-(void)messageSent:(SKPSMTPMessage *)message
{
    NSLog(@"发送成功");
}

-(void)messageFailed:(SKPSMTPMessage *)message error:(NSError *)error
{
    NSLog(@"发送失败");
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
